<?php
	$html->css('/forums/css/forums', null, array(), false);

	$html->addCrumb('Forums', array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'index'));
	foreach ($breadcrumbs as $key => $crumb)
	{
		if ($key == 0)
			$html->addCrumb($crumb['title'], array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'index', $crumb['slug']));
		else
			$html->addCrumb($crumb['title'], array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'forum', $crumb['slug']));
	}

	echo '<div class="breadcumbs">' . $html->getCrumbs(' > ') . '</div>';
	pr($threads);
?>
<div class="finalBreadcrumb"><?php echo $forum['ForumForum']['title']; ?></div>
<table>
	<tr>
		<th colspan="4">Subforums</th>
	</tr>
	<tr>
		<th>Forum</th>
		<th width="20%">Last post</th>
		<th width="10%">Threads</th>
		<th width="10%">Posts</th>
	</tr>
	<?php foreach ($subForums as $subForum) :?>
		<tr>
			<td>
				<?php echo $html->link($subForum['title'], array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'forum', $subForum['slug'])); ?><br />
				<?php echo $subForum['description']; ?>
				<?php if (count($subForum['ChildForum'])) :?>
				<br />Subforums:
					<?php foreach($subForum['ChildForum'] as $key => $ChildForum) : ?>
						<?php echo $html->link($ChildForum['title'],array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'forum', $ChildForum['slug'])); if($key < (count($subForum['ChildForum'])-1)) echo ", ";?>
					<?php endforeach; ?>
				<?php endif;?>
			</td>
			<td>
				<?php echo $subForum['lastPost']['ForumThread']['title'];?><br>
				by <?php echo $subForum['lastPost']['User']['username']; ?><br>
				<?php echo $time->niceShort($subForum['lastPost']['ForumPost']['created']);?>
			</td>
			<td><?php echo $subForum['number_threads']; ?></td>
			<td><?php echo $subForum['number_posts']; ?></td>
		</tr>
	<?php endforeach;?>
</table>
<?php echo $html->link('New topic', array('action' => 'newTopic', $forum['ForumForum']['slug']), array('id' => 'newTopic')); ?>
<table>
	<tr>
		<th>Thread</th>
		<th width="20%">Last post</th>
		<th width="10%">Replies</th>
		<th width="10%">Views</th>
	</tr>
<?php foreach ($threads as $thread) :?>
	<tr>
		<td>
			<?php echo $html->link($thread['title'], array('controller' => 'forums', 'plugin' => 'forums', 'action' => 'thread', $thread['slug'])); ?><br />
			<?php echo $thread['description']; ?>
		</td>
		<td>
			<?php echo $time->niceShort($thread['lastPost']['created']);?><br>
			by <?php echo $thread['lastPost']['User']['username']; ?>
		</td>
		<td><?php echo $thread['number_posts']; ?></td>
		<td><?php echo $thread['views']; ?></td>
	</tr>
<?php endforeach; ?>
</table>